# -*- coding=utf-8 -*-
# Author: Slp
# @Date : 2021-08-11


import requests


class OperatorCommon:

    @staticmethod
    def requestApi(request_url, request_data, headers, request_method, request_cookie, **kwargs):
        headers = eval(headers)  # 用来执行一个字符串表达式，并返回表达式的值
        if request_method.lower() == 'post':
            response = requests.post(url=request_url, data=request_data, headers=headers, cookies=request_cookie)
            return response
        elif request_method.lower() == 'get':
            response = requests.get(url=request_url, params=request_data, headers=headers, cookies=request_cookie)
            return response
        elif request_method.lower() == 'put':
            response = requests.put(url=request_url, data=request_data, headers=headers, cookies=request_cookie)
            return response
